#include <mockcpp/mockcpp.hpp>
#include <testngpp/testngpp.hpp>
#include <Quantity.h>
#include <Length.h>
#include <LengthUnit.h>
#include <LengthFormatter.h>
#include <sstream>

USING_MOCKCPP_NS
USING_TESTNGPP_NS

FIXTURE(LengthEqual)
{
    TEST(4 yard should equal to 4 yard)
    {
        ASSERT_TRUE(Length(4, YARD) == Length(4, YARD));
    }

    TEST(1 mile should equal to 1760 yard)
    {
        ASSERT_TRUE(Length(1, MILE) == Length(1760, YARD));
    }

    TEST(2 yard should equal to 6 feet)
    {
        ASSERT_TRUE(Length(2, YARD) == Length(6, FEET));
    }

};

FIXTURE(LengthNotEqual)
{
    TEST(6 mile should not equal to 5 mile)
    {
        ASSERT_TRUE(Length(6, MILE) != Length(5, MILE));
    }

    TEST(1761 yard should not equal to 1 mile)
    {
        ASSERT_TRUE(Length(1761, YARD) != Length(1, MILE));
    }

    TEST(2 yard should not equal to 10 feet)
    {
        ASSERT_TRUE(Length(2, YARD) != Length(10, FEET));
    }

    TEST(1 mile should not equal to 6000 feet)
    {
        ASSERT_TRUE(Length(1, MILE) != Length(6000, FEET));
    }

};

FIXTURE(LengthPlus)
{    
    TEST(20 feet + 30 feet should equal to 50 feet)
    {
        ASSERT_TRUE(Length(50, FEET) == (Length(20, FEET)+Length(30, FEET)));
    }

    TEST(1 mile + 10 yard should equal to 1770 yard)
    {
        ASSERT_TRUE(Length(1770, YARD) == (Length(10, YARD)+Length(1, MILE)));
    }

    TEST(1 mile + 10 feet should equal to 5290 feet)
    {
        ASSERT_TRUE(Length(5290, FEET) == (Length(1, MILE)+Length(10, FEET)));
    }

    TEST(3 yard + 10 feet should equal to 19 feet)
    {
        ASSERT_TRUE(Length(19, FEET) == (Length(3, YARD)+Length(10, FEET)));
    }

};

FIXTURE(LengthPrintInFormat1)
{
    std::ostringstream os;
    TEST(The output format of Length(3, MILE) should be: 3 MILE)
    {
        os<<LengthFormatter(Length(3, MILE), FormatInUnitOrder);
        ASSERT_EQ(std::string("3 MILE "), os.str());
    }

    TEST(The output format of Length(1800, YARD) should be: 1 MILE 40 YARD)
    {
        os<<LengthFormatter(Length(1800, YARD), FormatInUnitOrder);
        ASSERT_EQ(std::string("1 MILE 40 YARD "), os.str());
    }

    TEST(The output format of Length(4, YARD) should be: 4 YARD)
    {
        os<<LengthFormatter(Length(4, YARD), FormatInUnitOrder);
        ASSERT_EQ(std::string("4 YARD "), os.str());
    }

    TEST(The output format of Length(2, FEET) should be: 2 FEET)
    {
        os<<LengthFormatter(Length(2, FEET), FormatInUnitOrder);
        ASSERT_EQ(std::string("2 FEET "), os.str());
    }

    TEST(The output format of Length(5, FEET) should be: 1 YARD 2 FEET)
    {
        os<<LengthFormatter(Length(5, FEET), FormatInUnitOrder);
        ASSERT_EQ(std::string("1 YARD 2 FEET "), os.str());
    }

    TEST(The output format of Length(6001, FEET) should be: 1 MILE 240 YARD 1 FEET)
    {
        os<<LengthFormatter(Length(6001, FEET), FormatInUnitOrder);
        ASSERT_EQ(std::string("1 MILE 240 YARD 1 FEET "), os.str());
    }

    TEST(The output format of Length(5282, FEET) should be: 1 MILE 2 FEET)
    {
        os<<LengthFormatter(Length(5282, FEET), FormatInUnitOrder);
        ASSERT_EQ(std::string("1 MILE 2 FEET "), os.str());
    }

    TEST(The output format of Length(0, MILE) should be: 0 MILE)
    {
        os<<LengthFormatter(Length(0, MILE), FormatInUnitOrder);
        ASSERT_EQ(std::string("0 MILE "), os.str());
    }

    TEST(The output format of Length(0, YARD) should be: 0 YARD)
    {
        os<<LengthFormatter(Length(0, YARD), FormatInUnitOrder);
        ASSERT_EQ(std::string("0 YARD "), os.str());
    }

    TEST(The output format of Length(0, FEET) should be: 0 FEET)
    {        
        os<<LengthFormatter(Length(0, FEET), FormatInUnitOrder);
        ASSERT_EQ(std::string("0 FEET "), os.str());
    }
};

FIXTURE(LengthPrintInFormat2)
{
    std::ostringstream os;
    TEST(The output format of Length(1, MILE) should be: 5280 FEET)
    {
        os<<LengthFormatter(Length(1, MILE), FormatInBaseUnit);
        ASSERT_EQ(std::string("5280 FEET"), os.str());
    }

    TEST(The output format of Length(5, YARD) should be: 15 FEET)
    {
        os<<LengthFormatter(Length(5, YARD), FormatInBaseUnit);
        ASSERT_EQ(std::string("15 FEET"), os.str());
    }
};



